import 'dart:ui';

import '../video_model.dart';

class TagListModel {
  List<TagsBean>? hot;
  List<TagsBean>? newest;
  List<TagsBean>? playCount;
  List<TagsBean>? list;
  int? type = 0;
  bool? hasNext;

  static TagListModel fromJson(Map<String, dynamic>? map) {
    map ??= {};
    TagListModel tagListModelBean = TagListModel();
    tagListModelBean.hot = (map['hot'] as List?)?.map((o) => TagsBean.fromMap(o)).toList();
    tagListModelBean.newest = (map['newest'] as List?)?.map((o) => TagsBean.fromMap(o)).toList();
    tagListModelBean.playCount = (map['playCount'] as List?)?.map((o) => TagsBean.fromMap(o)).toList();
    tagListModelBean.list = (map['list'] as List?)?.map((o) => TagsBean.fromMap(o)).toList();
    tagListModelBean.hasNext = map['hasNext'];
    return tagListModelBean;
  }

  Map toJson() => {
        "hot": hot,
        "newest": newest,
        "playCount": playCount,
      };
}

class TagDetailModel {
  String? id;
  String? name;
  String? coverImg;
  String? description;
//  String? hotIcon;
  bool? hasCollected;
  int? playCount;
  int? searchType; //  0 默认; 1 推荐; 2 热门
  // ui ????
  bool? isSelected = false;

  // 视频搜索新增字段
  String? desc;
  int? types;
  int? videoCount;
  static TagDetailModel fromJson(Map<String, dynamic>? map) {
    map ??= {};
    TagDetailModel tagDetailModelBean = TagDetailModel();
    tagDetailModelBean.id = map['id'];
    tagDetailModelBean.name = map['name'];
    tagDetailModelBean.coverImg = map['coverImg'];
    tagDetailModelBean.description = map['description'];
    tagDetailModelBean.hasCollected = map['hasCollected'];
    tagDetailModelBean.playCount = map['playCount'];
    tagDetailModelBean.searchType = map['searchType'];
    tagDetailModelBean.desc = map['desc'];
    tagDetailModelBean.types = map['types'];
    tagDetailModelBean.videoCount = map['videoCount'];

    return tagDetailModelBean;
  }

  Map toJson() => {
        "id": id,
        "name": name,
        "coverImg": coverImg,
        "description": description,
        "hasCollected": hasCollected,
        "playCount": playCount,
      };

  static List<TagDetailModel> toList(List<dynamic> mapList) {
    List<TagDetailModel> list = [];
    Iterator iterator = mapList.iterator;
    while (iterator.moveNext()) {
      Map<String, dynamic> current = iterator.current;
      list.add(fromJson(current));
    }
    return list;
  }

  /// 视频搜索主页专用 根据types 查看标签类型
  String get tagTypeDesc {
    if (types == null) return '';
    return ['荐', '热', '新'][types!];
  }

  Color get tagTypesColor {
    return [Color(0xffFD0563), Color(0xffF85B54), Color(0xffFFB025)][types!];
  }
}
